package com.org.devg.elasticsearch;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author devg
 * @Date 2019/10/13 17:44
 */
public class EsUtil {

    /**
     * 时间转化成 String 格式的时间
     *
     * @param dateFormat
     * @param millSec
     * @return
     */
    public static String transferDateToString(String dateFormat, Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        String resDate = sdf.format(date);
        return resDate;
    }

    public static Date transferStringToDate(String dateFormat, String date) {
        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
        try {
            return sdf.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }

    public static boolean isNullOrEmpty(String str) {
        return str == null || str.trim().equals("");
    }


}
